package com.sanmubird.mywebframework.eventbus.demo;


import com.sanmubird.mywebframework.eventbus.core.MqExchangeEnum;
import com.sanmubird.mywebframework.eventbus.core.MqMessage;
import com.sanmubird.mywebframework.eventbus.core.MqPublisher;
import com.sanmubird.mywebframework.eventbus.demo.direct.DemoDirectData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class MqDemoController {

    @Autowired
    private MqPublisher mqPublisher;


    @GetMapping("/test/mq")
    public String mq() {
        MqMessage<DemoDirectData> mqMessage = new MqMessage<>(MqExchangeEnum.DEMO_DIRECT_EXCHANGE.getRoutingKey(), new DemoDirectData("Hello, world!"));
        mqPublisher.publish(mqMessage);
        return "ok";
    }
}
